/*
 * main.cpp
 *
 *  Created on: 2008-11-25
 *      Author: fanliangliang
 */

#include "toxic.h"

#if defined(PLATFORM_WIN32)

#include "receiver_service.h"

int main(int argc, char** argv) {
	ReceiverService service("xreceiver");
	if (!service.parseArguments(argc, argv)) {
		if (service.isInstalled()) {
			if (!service.start()) {
				printf("The service can not run from command line.\n");
			}
		}
		else {
			printf("The service is not installed, use \"%s -i\" to install.\n", argv[0]);
		}
	}
	return 0;
}

#else

#include "application.h"
#include <iostream>
#include <unistd.h>

using namespace std;

int main(int argc, char** argv) {

	daemon(1, 0);

	try {
		Application app;
		app.start();

		while (true) {
			Thread::sleep(200);
		}

		app.stop();
	}
	catch (const exception& e) {
		cerr << e.what() << endl;
	}

	return 0;
}

#endif

/*
#include "application.h"
#include "toxic.h"
#include <iostream>
#include "utility.h"
#include <vector>
#include <fstream>

using namespace std;
using namespace toxic;

int main() {

	try {
		Application app;
		app.start();

		Thread::sleep(30000);

		app.stop();
	}
	catch (const exception& e) {
		cerr << e.what() << endl;
	}
	catch (...) {
		xerror << "oops, caught an unexpected exception";
	}

	xlog.shutdown();

	return 0;
}
*/
